<?php include $this->admin_tpl('meta', 'admin');?>
<title>添加规则</title>
<meta name="referrer" content="no-referrer" />
</head>
<body>
<article class="page-container">
    <form class="form form-horizontal" onsubmit="return dosub(this)" method="get">
		<input type="hidden" name="id" value="<?php echo $info['id'];?>">
		<input type="hidden" name="dosubmit" value="1">
		<div class="row cl">
			<label class="form-label col-xs-3"><span class="c-red">*</span>品牌：</label>
			<div class="formControls col-xs-8 col-sm-9">
			<span class="select-box inline">
				<?php
					//$brand_list = ['全局','默认','雅鹿','法派FAPAI','增致牛仔 ZENGZHI','东方骆驼'];
					$brand = isset($info['brand']) ? trim($info['brand']) : '默认';
					$sku_tag_brand = sku_tag_brand();
					array_unshift($sku_tag_brand,'默认');
				?>
				<select name="brand" class="select">
				<?php foreach($sku_tag_brand as $v){?>
					<option value="<?php echo $v;?>" <?if($brand == $v){echo 'selected';}?>><?php echo $v;?></option>
				<?php } ?>	
				</select>
			</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3"><span class="c-red"></span> 标签名称：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="<?php echo $info['tag_name'];?>"  name="tag_name">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3"><span class="c-red"></span> 7天日均：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="<?php echo $info['days_avg'];?>"  name="days_avg">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3"><span class="c-red"></span> 备货天数：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="<?php echo $info['days_num'];?>"  name="days_num">
			</div>
		</div>
		<?php if($info['days_num']>0){?>
		<div class="row cl">
			<label class="form-label col-xs-3"><span class="c-red"></span> 补货依据：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<?php 
				$arr = [2,3,5,7];
				foreach($arr as $v){
					$str = '';
					$info['days'] = isset($info['days']) ? $info['days'] : 5;
					if($v==$info['days']){
						$str = 'checked';
					}
				?>
				<label class="label_radio"><input name="days" type="radio" <?php echo $str;?> value="<?php echo $v;?>"> <?php echo $v;?>天日均</label>
				<?php } ?>
				<a class="yzm-tips" href="javascript:void(0);" onmouseover="yzm_tips = layer.tips($(this).parent().find('span.yzm-explain').html(), this, {time:100000});" onmouseout="layer.close(yzm_tips);"><i class="Hui-iconfont yzm-tips-icon"></i></a><span class="yzm-explain">根据该设置销量日均补货</span>
			</div>
		</div>
		<?php } ?>
		<div class="row cl">
			<label class="form-label col-xs-3"><span class="c-red"></span> 备注：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="<?php echo $info['remark'];?>"  name="remark">
			</div>
		</div>
		<div style="margin-top:20px;margin-left:10px;text-align:center;">
			<button name="dosubmit" class="btn btn-primary radius" type="submit">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>&nbsp;&nbsp;&nbsp;&nbsp;
			<button onclick="yzmcms_close()" class="btn btn-default radius" type="button">&nbsp;&nbsp;关闭&nbsp;&nbsp;</button>
		</div>
    </form>

</article>
<?php include $this->admin_tpl('footer', 'admin');?>

<script type="text/javascript">
function dosub(obj){
	if($("input[name='tag_name']").val()==''){
		layer.msg('标签名称！', {icon:2});
		return false;
	}
	if(!$.isNumeric($("input[name='days_avg']").val())){
		layer.msg('日均必须是正整数', {icon:2});
		return false;
	}
	if(!$.isNumeric($("input[name='days_avg']").val())){
		layer.msg('备货天数必须是正整数', {icon:2});
		return false;
	}
	if($("input[name='remark']").val()==''){
		layer.msg('备注说明不能为空！', {icon:2});
		return false;
	}
	<?php if($info['id']){?>
	let url = '<?php echo U('wp_buhuo',['type'=>'tag_edit','brand'=>$brand])?>';
	<?php }else{ ?>
	let url = '<?php echo U('wp_buhuo',['type'=>'tag_add','brand'=>$brand])?>';
	<?php }?>
	$.ajax({
		type: 'get',
		url: url, 
		data: $(obj).serialize(),
		dataType: "json", 
		success: function (msg) {
			if(msg.status == 1){
				layer.msg(msg.message, {icon:1, time:800}, function(){
					window.parent.select();
				});
		    }else{
				layer.msg(msg.message, {icon:2});
			}
		}
	})
	return false;		
}
</script> 

</body>
</html>